Skip to content

Access AgentRunResult.usage as a property in common.ai logging#68405

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-agentrunresult-usage-property
Jun 12, 2026
Merged

Access AgentRunResult.usage as a property in common.ai logging#68405
kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-agentrunresult-usage-property

Conversation

@kaxil

@kaxil kaxil commented Jun 11, 2026

Copy link
Copy Markdown
Member

pydantic-ai deprecated calling AgentRunResult.usage() as a method, so every agent run that goes through log_run_summary currently emits a PydanticAIDeprecationWarning in task logs. This drops the parentheses at the single call site and updates the test mocks to set .usage as an attribute instead of a return_value.

No version-floor bump is needed: the provider floor pydantic-ai-slim>=1.99.0 already exposes usage as a deprecated-callable property (both access forms work there), so property access is valid across the whole supported range. Verified by running log_run_summary against a real AgentRunResult with PydanticAIDeprecationWarning escalated to an error: the property form is clean and the old method-call form raises.

image

pydantic-ai deprecated calling AgentRunResult.usage() as a method
(PydanticAIDeprecationWarning); it is a property since the version range
already covered by the provider floor (pydantic-ai-slim>=1.99.0 exposes
both forms). Drop the parentheses at the call site and update the test
mocks to set .usage as an attribute instead of a return_value.
@kaxil kaxil merged commit 1c40bfb into apache:main Jun 12, 2026
78 of 79 checks passed
@kaxil kaxil deleted the fix-agentrunresult-usage-property branch June 12, 2026 19:45
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Jun 16, 2026
…e#68405)

pydantic-ai deprecated calling AgentRunResult.usage() as a method
(PydanticAIDeprecationWarning); it is a property since the version range
already covered by the provider floor (pydantic-ai-slim>=1.99.0 exposes
both forms). Drop the parentheses at the call site and update the test
mocks to set .usage as an attribute instead of a return_value.
dingo4dev pushed a commit to dingo4dev/airflow that referenced this pull request Jun 16, 2026
…e#68405)

pydantic-ai deprecated calling AgentRunResult.usage() as a method
(PydanticAIDeprecationWarning); it is a property since the version range
already covered by the provider floor (pydantic-ai-slim>=1.99.0 exposes
both forms). Drop the parentheses at the call site and update the test
mocks to set .usage as an attribute instead of a return_value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants